/* c1.c
 *	Simple program to help perform multi-client test using networking to implement lock/cv/mv-related syscalls
 *	
 *	Does syscalls that create, acquire, release, and destroy locks and create, wait, signal, broadcast, and destory CVs, create, set, get, destory MVs
 *  through connection to a server. Will be used with one single-threaded server process and up to 5 single-threaded client processes.
 */
#include "syscall.h"

int main(int argc, char **argv)
{   
	int lockIndex, cvIndex, mvIndex, lock2, lock3, lock4, lock5, lock6, lock7, lock8, lock9, lock10, lock11, cv2,cv3, cv4, cv5, cv6, cv7, cv8, cv9, cv10,cv11,mv2,mv3;
	PrintOut("\nClient 1: Create Lock, CV, MV, acquire, set MV, wait, release.\n", 64); 
    lockIndex = CreateLock("BobLock", 7, 1);
	lock2 = CreateLock("B2bLock", 7, 1);
	lock3 = CreateLock("B3bLock", 7, 1);
	lock4 = CreateLock("B4bLock", 7, 1);
	lock5 = CreateLock("B5bLock", 7, 1);
	lock6 = CreateLock("B6bLock", 7, 1);
	lock7 = CreateLock("B7bLock", 7, 1);
	lock8 = CreateLock("B8bLock", 7, 1);
	lock9 = CreateLock("B9bLock", 7, 1);
	lock10 = CreateLock("B10bLock", 8, 1);
	lock11 = CreateLock("B11bLock", 8, 1);
	lockIndex = CreateLock("BobLock", 7, 1);
	
	cvIndex = CreateCV("BobCV", 5, 1);
	cv2 = CreateCV("B2bCV", 5, 1);
	cv3= CreateCV("B3bCV", 5, 1);
	cv4 = CreateCV("B4bCV", 5, 1);
	cv5= CreateCV("B5bCV", 5, 1);
	cv6 = CreateCV("B6bCV", 5, 1);
	cv7= CreateCV("B7bCV", 5, 1);
	cv8 = CreateCV("B82bCV", 5, 1);
	cv9 = CreateCV("B9bCV", 5, 1);
	cv10 = CreateCV("B10bCV", 6, 1);
	cv11 = CreateCV("B11bCV", 6, 1);
	cvIndex = CreateCV("BobCV", 5, 1);
	
	
	mvIndex = CreateMV("BobMV", 5, 1);
	mv2 = CreateMV("B2bMV", 5, 1);
	mv3 = CreateMV("B3bMV", 5, 1);
	mv2 = CreateMV("B2bMV", 5, 1);
	mvIndex = CreateMV("BobMV", 5, 1);



	Acquire(lockIndex);
	Acquire(lock2);
	Acquire(lock3);
	Acquire(lock4);

	SetMV(mvIndex, 1); /*first int is index of MV, and second int is value to set it to*/
					   /*Setting it to one so Client 5 knows it's waiting and will wake it up*/
	
	
	Wait(cv11, lock11);
	
	/* Then we're done!*/ 
    Halt(); /*MUST do since using networking (post office has own thread)*/
}

